<?php


/**
 * Notes:
 * PROJECT_NAME : ERP v1.8 重构erp
 * User: 夏鱼儿<397072174@qq.com>
 * Date: 2024/1/6
 * Time: 9:30
 */

namespace app\service\traits\model;

use app\admin\model\Company;
use app\admin\model\CompanyOrderLog;
use app\admin\model\Goods;
use app\admin\model\GoodsCate;
use app\admin\model\GoodsRule;
use app\admin\model\GoodsSpec;
use app\admin\model\CompanyUser;
use app\company\model\CompanyDividend;
use app\company\model\CompanyGoods;
use app\company\model\CompanyGoodsRule;
use app\company\model\CompanyOrder;
use app\company\model\CompanyOrderDetail;
use app\company\model\CompanyOrderStorage;
use app\company\model\CompanyRoleMenu;
use app\company\model\CompanyUserRole;
use app\company\model\ConfigMini;
use app\company\model\Store;
use app\company\model\StoreOrderProfit;
use app\company\model\StoreSupplier;
use app\company\model\StoreUser;
use app\company\model\StoreUserAccount;
use app\company\model\StoreUserAccountDetail;
use app\company\model\StoreUserBank;
use app\company\model\StoreUserCredit;
use app\company\model\Supplier;
use app\company\model\SupplierUser;
use app\mini\model\StoreOrder;
use app\mini\model\StoreOrderDetail;
use app\company\model\StoreOrderLog;
use app\mini\model\StoreUserOauth;
use app\service\traits\model\lines\Admin;
use app\service\traits\model\lines\Deliver;
use app\service\traits\model\lines\WarehouseLines;
use think\model\relation\BelongsTo;
use think\model\relation\HasMany;
use think\model\relation\HasManyThrough;
use think\model\relation\HasOne;

/**
 *  Class Line
 *  关联方法 方法名定义如下
 *  模型名 代表 belongsTo 关联方法
 *  模型名 + s 代表 hasMany 关联方法
 *  模型名 + o  代表 hasOne 关联方法
 *  模型名 + o s  代表 hasOneThrough 关联方法
 *  模型名 + o + s  代表 hasOneOrMany 关联方法
 *  模型名 + s + m  代表 hasManyThrough 关联方法 远程一对多
 *  模型名 + m 代表 morphTo 关联方法
 *  模型名 + m + s data 代表 morphToMany 关联方法
 *  模型名 + m + o data 代表 morphToOne 关联方法
 *  模型名 + m + o + s data 代表 morphToOneThrough 关联方法
 *  模型名 + m + o + s + p data 代表 morphToOneThrough 关联方法
 *
 * @property  CompanyUser $companyUsers
 * @property  CompanyUser $companyUser
 * @property  GoodsSpec $goodsSpec
 * @property  GoodsRule $goodsRules
 * @property  GoodsRule $goodsRule
 * @property  GoodsCate $goodsCate
 * @property  GoodsCate $goodsCates
 * @property  CompanyDividend $companyDividendO
 * @property  CompanyDividend $companyDividend
 * @property  CompanyOrder $companyOrder
 * @property  CompanyOrder $companyOrders
 * @property  CompanyOrderDetail $companyOrderDetail
 * @property  CompanyOrderDetail $companyOrderDetails
 * @property  CompanyOrderDetail $companyOrderDetailSM
 * @property  Goods $goods
 * @property  SupplierUser $supplierUser
 * @property  SupplierUser $supplierUsers
 * @property  Supplier $supplier
 * @property  companyOrderStorage $companyOrderStorages
 * @property  companyOrderStorage $companyOrderStorage
 * @property  companyOrderStorage $companyOrderStorageO
 * @property  companyGoodsRule $companyGoodsRule
 * @property  companyGoodsRule $companyGoodsRules
 * @property  CompanyGoods $companyGoods
 * @property  CompanyGoods $companyGoodss
 * @property  StoreUserBank $StoreUserBank
 * @property  StoreUserBank $storeUserBanks
 * @property  StoreUser $storeUser
 * @property  StoreUser $storeUsers
 * @property  Store $store
 * @property  Store $stores
 * @property  CompanyRoleMenu $companyRoleMenus
 * @property  CompanyUserRole $companyUserRoles
 * @property  StoreUserAccount $storeUserAccount
 * @property  StoreUserAccount $storeUserAccountO
 * @property  StoreUserAccountDetail $storeUserAccountDetail
 * @property  StoreUserAccountDetail $storeUserAccountDetails
 * @property  StoreOrderDetail $storeOrderDetail
 * @property  StoreOrderDetail $storeOrderDetails
 * @property  StoreOrderDetail $storeOrderDetailsO
 * @property  StoreOrderDetail $storeOrderDetailSM($map)
 * @property  StoreOrder $storeOrder
 * @property  StoreOrder $storeOrders
 * @property  StoreOrder $storeOrdersO
 * @property  StoreSupplier $storeSupplier
 * @property  StoreSupplier $storeSuppliers
 * @property  StoreSupplier $storeSupplierO
 * @property  storeUserOauth $storeUserOauths
 * @property  StoreOrderLog $storeOrderLogs
 * @property  StoreUserCredit $storeUserCredit
 * @property  StoreUserCredit $storeUserCredits
 * @property  StoreUserCredit $storeUserCreditO
 * @property  StoreUserCredit $storeUserCreditSM
 * @property  StoreOrderProfit storeOrderProfit
 * @property  StoreOrderProfit $storeOrderProfitO
 * @property  StoreOrderProfit $storeOrderProfits
 * @property  ConfigMini $configMini
 * @property  ConfigMini $configMiniO
 * @property  ConfigMini $configMinis
 */
trait Line
{

    use Deliver;
    use lines\Company;
    use WarehouseLines;
    use Admin;

    /**
     * 关联商品表
     * @return BelongsTo
     */
    public function goods(): BelongsTo
    {
        return $this->belongsTo(Goods::class);
    }

    /**
     * 关联商品规则表
     * @return HasMany
     */
    public function goodsRules(): HasMany
    {
        return $this->hasMany(GoodsRule::class);
    }

    /**
     * 关联分类表
     * @return BelongsTo
     */
    public function goodsCate(): BelongsTo
    {
        return $this->belongsTo(GoodsCate::class);
    }

    /**
     * 关联商品分类表
     * @return HasMany
     */
    public function goodsCates(): HasMany
    {
        return $this->hasMany(GoodsCate::class);
    }

    /**
     * 关联商品规则表
     * @return BelongsTo
     */
    public function goodsRule(): BelongsTo
    {
        return $this->belongsTo(GoodsRule::class);
    }

    /**
     * 关联商品规则组表
     * @return HasMany
     */
    public function goodsSpecs(): HasMany
    {
        return $this->hasMany(GoodsSpec::class);
    }

    /**
     * 关联商品规则组表
     * @return HasMany
     */
    public function companyUsers(): HasMany
    {
        return $this->hasMany(CompanyUser::class);
    }

    /**
     * 关联商品规则组表
     * @return belongsTo
     */
    public function companyUser(): belongsTo
    {
        return $this->belongsTo(CompanyUser::class);
    }

    /**
     * 关联分红组表
     * @return belongsTo
     */
    public function companyDividend(): belongsTo
    {
        return $this->belongsTo(CompanyDividend::class);
    }

    /**
     * 关联分红组表
     * @return belongsTo
     */
    public function companyDividendO(): belongsTo
    {
        return $this->belongsTo(CompanyDividend::class);
    }


    /**
     * 关联order表
     * @return belongsTo
     */
    public function companyOrder(): belongsTo
    {
        return $this->belongsTo(CompanyOrder::class);
    }

    /**
     * 关联order表
     * @return HasMany
     */
    public function companyOrders(): HasMany
    {
        return $this->HasMany(CompanyOrder::class);
    }

    /**
     * 关联orderDetail表
     * @return belongsTo
     */
    public function companyOrderDetail(): belongsTo
    {
        return $this->belongsTo(CompanyOrderDetail::class);
    }

    /**
     * 关联orderDetail表
     * @return hasMany
     */
    public function companyOrderDetails(): hasMany
    {
        return $this->hasMany(CompanyOrderDetail::class);
    }

    /**
     * 关联orderDetail表
     * @return hasManyThrough
     */
    public function companyOrderDetailSM(): hasManyThrough
    {
        return $this->hasManyThrough(CompanyOrderDetail::class, CompanyOrder::class)->where('order_status', 5);
    }


    /**
     * 关联orderLog日志表
     * @return hasMany
     */
    public function companyOrderLogs(): hasMany
    {
        return $this->hasMany(CompanyOrderLog::class);
    }

    /**
     * 关联公司表
     * @return belongsTo
     */
    public function company(): belongsTo
    {
        return $this->belongsTo(Company::class);
    }

    /**
     * 关联第三方表
     * @return belongsTo
     */
    public function supplier(): belongsTo
    {
        return $this->belongsTo(Supplier::class);
    }

    /**
     * 关联第三方表用户表
     * @return belongsTo
     */
    public function supplierUser(): belongsTo
    {
        return $this->belongsTo(SupplierUser::class);
    }

    /**
     * 关联第三方表用户表
     * @return hasMany
     */
    public function supplierUsers(): hasMany
    {
        return $this->hasMany(SupplierUser::class);
    }


    /**
     * 关联仓库库位详情表
     * @return hasMany
     */
    public function companyOrderStorages(): hasMany
    {
        return $this->hasMany(CompanyOrderStorage::class);
    }

    /**
     * 关联仓库库位详情表
     * @return BelongsTo
     */
    public function companyOrderStorage(): BelongsTo
    {
        return $this->BelongsTo(CompanyOrderStorage::class);
    }

    /**
     * 关联仓库库位详情表
     * @return HasOne
     */
    public function companyOrderStorageO(): HasOne
    {
        return $this->HasOne(CompanyOrderStorage::class);
    }

    /**
     * 关联公司商品规格表
     * @return BelongsTo
     */
    public function companyGoodsRule(): BelongsTo
    {
        return $this->BelongsTo(CompanyGoodsRule::class);
    }

    /**
     * 关联公司商品规格表
     * @return hasMany
     */
    public function companyGoodsRules(): hasMany
    {
        return $this->hasMany(CompanyGoodsRule::class);
    }

    /**
     * 关联公司商品表
     * @return BelongsTo
     */
    public function companyGoods(): BelongsTo
    {
        return $this->BelongsTo(CompanyGoods::class);
    }

    /**
     * 关联公司商品表
     * @return hasMany
     */
    public function companyGoodss(): hasMany
    {
        return $this->hasMany(CompanyGoods::class);
    }

    /**
     * 关联公司门店表
     * @return BelongsTo
     */
    public function store(): BelongsTo
    {
        return $this->BelongsTo(Store::class);
    }

    /**
     * 关联公司门店表
     * @return hasMany
     */
    public function stores(): hasMany
    {
        return $this->hasMany(Store::class);
    }

    /**
     * 关联公司-门店-用户表
     * @return BelongsTo
     */
    public function storeUser(): BelongsTo
    {
        return $this->BelongsTo(StoreUser::class);
    }

    /**
     * 关联公司-门店-用户表
     * @return hasMany
     */
    public function storeUsers(): hasMany
    {
        return $this->hasMany(StoreUser::class);
    }

    /**
     * 关联公司-门店-用户-银行卡表
     * @return BelongsTo
     */
    public function storeBank(): BelongsTo
    {
        return $this->BelongsTo(StoreUserBank::class);
    }

    /**
     * 关联公司-门店-用户-银行卡表
     * @return hasMany
     */
    public function storeUserBanks(): hasMany
    {
        return $this->hasMany(StoreUserBank::class);
    }

    /**
     * 关联公司-角色-菜单表
     * @return hasMany
     */
    public function companyRoleMenus(): hasMany
    {
        return $this->hasMany(CompanyRoleMenu::class);
    }

    /**
     * 关联公司-用户-角色表
     * @return hasMany
     */
    public function companyUserRoles(): hasMany
    {
        return $this->hasMany(CompanyUserRole::class);
    }


    /**
     * 关联公司-门店-用户-账户表
     * @return belongsTo
     */
    public function storeUserAccount(): belongsTo
    {
        return $this->belongsTo(StoreUserAccount::class);
    }

    /**
     * 关联公司-门店-用户-账户表
     * @return hasOne
     */
    public function storeUserAccountO(): hasOne
    {
        return $this->hasOne(StoreUserAccount::class);
    }

    /**
     * 关联公司-门店-用户-账户明细表
     * @return belongsTo
     */
    public function storeUserAccountDetail(): belongsTo
    {
        return $this->belongsTo(StoreUserAccountDetail::class);
    }

    /**
     * 关联公司-门店-用户-账户明细表
     * @return hasMany
     */
    public function storeUserAccountDetails(): hasMany
    {
        return $this->hasMany(StoreUserAccountDetail::class);
    }

    /**
     * 关联公司-门店-订单细表
     * @return hasMany
     */
    public function storeOrderDetails(): hasMany
    {
        return $this->hasMany(StoreOrderDetail::class);
    }

    /**
     * 关联orderDetail表
     * @param $map
     * @return hasManyThrough
     */
    public function storeOrderDetailSM($map): hasManyThrough
    {
        return $this->hasManyThrough(StoreOrderDetail::class, StoreOrder::class)->where($map);
    }

    /**
     * 关联公司-门店-订单细表
     * @return belongsTo
     */
    public function storeOrderDetail(): belongsTo
    {
        return $this->belongsTo(StoreOrderDetail::class);
    }

    /**
     * 关联公司-门店-订单细表
     * @return hasOne
     */
    public function storeOrderDetailO(): hasOne
    {
        return $this->hasOne(StoreOrderDetail::class);
    }

    /**
     * 关联公司-门店-订单表
     * @return hasOne
     */
    public function storeOrderO(): hasOne
    {
        return $this->hasOne(StoreOrder::class);
    }

    /**
     * 关联公司-门店-订单表
     * @return BelongsTo
     */
    public function storeOrder(): belongsTo
    {
        return $this->belongsTo(StoreOrder::class);
    }

    /**
     * 关联公司-门店-订单表
     * @return hasMany
     */
    public function storeOrders(): hasMany
    {
        return $this->hasMany(StoreOrder::class);
    }

    /**
     * 关联公司-门店-第三方表
     * @return hasOne
     */
    public function storeSupplierO(): hasOne
    {
        return $this->hasOne(StoreSupplier::class);
    }

    /**
     * 关联公司-门店-第三方表
     * @return BelongsTo
     */
    public function storeSupplier(): belongsTo
    {
        return $this->belongsTo(StoreSupplier::class);
    }

    /**
     * 关联公司-门店-第三方表
     * @return hasMany
     */
    public function storeSuppliers(): hasMany
    {
        return $this->hasMany(StoreSupplier::class);
    }

    /**
     * 关联公司-门店-用户-第三方登录表
     * @return hasMany
     */
    public function storeUserOauths(): hasMany
    {
        return $this->hasMany(StoreUserOauth::class);
    }

    /**
     * 关联公司-门店-订单-状态流转表
     * @return hasMany
     */
    public function storeOrderLogs(): hasMany
    {
        return $this->hasMany(StoreOrderLog::class);
    }

    /**
     * 关联公司-门店-用户-账单
     * @return hasMany
     */
    public function storeUserCredits(): hasMany
    {
        return $this->hasMany(StoreUserCredit::class);
    }

    /**
     * 关联公司-门店-用户-账单
     * @return belongsTo
     */
    public function storeUserCredit(): belongsTo
    {
        return $this->belongsTo(StoreUserCredit::class);
    }

    /**
     * 关联公司-门店-用户-账单
     * @return hasOne
     */
    public function storeUserCreditO(): hasOne
    {
        return $this->hasOne(StoreUserCredit::class);
    }

    /**
     * 关联公司-门店-用户-账单
     * @param $map
     * @return hasManyThrough
     */
    public function storeUserCreditSM($map): hasManyThrough
    {
        return $this->hasManyThrough(StoreUserCredit::class, StoreUser::class)->where($map);
    }

    /**
     * 关联公司-门店-订单-分佣
     * @return hasOne
     */
    public function storeOrderProfitO(): hasOne
    {
        return $this->hasOne(StoreOrderProfit::class);
    }


    /**
     * 关联公司-门店-订单-分佣
     * @return hasMany
     */
    public function storeOrderProfits(): hasMany
    {
        return $this->hasMany(StoreOrderProfit::class);
    }

    /**
     * 关联公司-门店-订单-分佣
     * @return belongsTo
     */
    public function storeOrderProfit(): belongsTo
    {
        return $this->belongsTo(StoreOrderProfit::class);
    }

    /**
     * 关联公司-小程序配置
     * @return belongsTo
     */
    public function configMini(): belongsTo
    {
        return $this->belongsTo(ConfigMini::class);
    }

    /**
     * 关联公司-小程序配置
     * @return hasMany
     */
    public function configMinis(): hasMany
    {
        return $this->hasMany(ConfigMini::class);
    }

    /**
     * 关联公司-小程序配置
     * @return hasOne
     */
    public function configMiniO(): hasOne
    {
        return $this->hasOne(ConfigMini::class);
    }


}